home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / src / smphone / ph_ioslave.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-11  |  4.4 KB  |  173 lines

  1. #include "util.h"
  2. #include "mmdf.h"
  3. #include "ph.h"
  4. /*
  5.  *     MULTI-CHANNEL MEMO DISTRIBUTION FACILITY  (MMDF)
  6.  *     
  7.  *
  8.  *     Copyright (C) 1979,1980,1981  University of Delaware
  9.  *     
  10.  *     Department of Electrical Engineering
  11.  *     University of Delaware
  12.  *     Newark, Delaware  19711
  13.  *
  14.  *     Phone:  (302) 738-1163
  15.  *     
  16.  *     
  17.  *     This program module was developed as part of the University
  18.  *     of Delaware's Multi-Channel Memo Distribution Facility (MMDF).
  19.  *     
  20.  *     Acquisition, use, and distribution of this module and its listings
  21.  *     are subject restricted to the terms of a license agreement.
  22.  *     Documents describing systems using this module must cite its source.
  23.  *
  24.  *     The above statements must be retained with all copies of this
  25.  *     program and may not be removed without the consent of the
  26.  *     University of Delaware.
  27.  *     
  28.  *
  29.  *     version  -1    David H. Crocker    March   1979
  30.  *     version   0    David H. Crocker    April   1980
  31.  *     version  v7    David H. Crocker    May     1981
  32.  *     version   1    David H. Crocker    October 1981
  33.  *
  34.  */
  35. /*#define RUNALON   */
  36.  
  37. /*                  Handle telephone-based i/o                          */
  38.  
  39. /*  May 82  D. Crocker  add chan.log rmsg/wmsg stats, like ch_phone has
  40.  *  Mar 84  D. Long     add use of per-channel phone transcripts
  41.  */
  42.  
  43. #include "ch.h"
  44. #include "phs.h"
  45. #include "d_returns.h"
  46.  
  47. extern struct ll_struct    *logptr,
  48.                 ph_log;
  49. extern char *logdfldir;
  50. extern char *def_trn;
  51. extern char *supportaddr;
  52. extern struct ps_rstruct ps_rp;
  53.  
  54. LOCVAR Chan *ph_curchan;
  55. LOCVAR char *ph_trn;
  56.  
  57. /* *********  (ph_)  PHONE MAIL SLAVE INIT/END SUB-MODULE  ************ */
  58.  
  59. ph_init (curchan)                 /* we are slave: initialize channel   */
  60.     Chan *curchan;
  61. {
  62.     extern char *dupfpath ();
  63.     short retval;
  64.  
  65. #ifdef DEBUG
  66.     ll_log (logptr, LLOGBTR, "ph_init (%s)", curchan -> ch_name);
  67. #endif
  68.  
  69.     ph_curchan = curchan;
  70.     ph_log.ll_hdr = logptr -> ll_hdr;
  71.     ph_log.ll_file = dupfpath (ph_log.ll_file, logdfldir);
  72.                   /* fill-out path to log file         */
  73.     if (curchan -> ch_trans == (char *) DEFTRANS)
  74.        ph_trn = dupfpath (def_trn, logdfldir);
  75.     else
  76.        ph_trn = dupfpath (curchan -> ch_trans, logdfldir);
  77.     phs_note (curchan, PHS_CNSTRT);
  78. #ifndef RUNALON
  79.     if ((retval = d_slvconn (&ph_log, TRUE, ph_trn,
  80.             (ph_log.ll_level >= LLOGBTR) ? TRUE : FALSE,
  81.             0, DL_RCVSZ, DL_XMTSZ) < D_OK))
  82.     {                  /* standard i/o port, max buf sizes   */
  83.     ll_log (logptr, LLOGTMP, "dial package problem with startup");
  84.     return (ph_d2rpval (retval));
  85.     }
  86. #endif
  87.  
  88.     phs_note (curchan, PHS_CNGOT);
  89.  
  90.     return (RP_OK);
  91. }
  92.  
  93. /* ARGSUSED */
  94.  
  95. ph_end (type)                     /* say goodbye to the caller          */
  96. short     type;               
  97. {
  98.  
  99. #ifdef DEBUG
  100.     ll_log (logptr, LLOGBTR, "ph_end ()");
  101. #endif
  102. #ifndef RUNALON
  103.     d_slvdrop (0);          /* always just drop the line          */
  104. #endif
  105.  
  106.     phs_end (ph_curchan, type ? RP_NO : RP_OK);
  107.     ph_curchan = OK;
  108.     return (RP_OK);
  109. }
  110.  
  111. /* */
  112.  
  113. ph_sbinit ()                      /* ready to submit to remote site     */
  114. {
  115.     char linebuf[LINESIZE];
  116.  
  117. #ifdef DEBUG
  118.     ll_log (logptr, LLOGBTR, "ph_sbinit ()");
  119. #endif
  120.  
  121.     if (rp_isbad (ps_irdrply ()) ||
  122.         rp_isbad (ps_rp.sm_rval != 220))
  123.     {
  124.     ll_log (logptr, LLOGFAT, "no greeting");
  125.     return (RP_NO);
  126.     }
  127.  
  128.     if (ph_curchan -> ch_confstr)
  129.     sprintf (linebuf, "HELO %s", ph_curchan -> ch_confstr);
  130.     else
  131.     sprintf (linebuf, "HELO %s.%s", ph_curchan -> ch_lname,
  132.                     ph_curchan -> ch_ldomain);
  133.     if (rp_isbad (ps_cmd( linebuf )) || ps_rp.sm_rval != 250 ) {
  134.     ll_log(logptr, LLOGFAT, "bad response to HELO");
  135.     return (RP_NO);
  136.     }
  137.  
  138.     return (RP_OK);
  139. }
  140.  
  141. ph_sbend ()                       /* done with submission               */
  142. {
  143. #ifdef DEBUG
  144.     ll_log (logptr, LLOGBTR, "ph_sbend ()");
  145. #endif
  146.      return (ps_cmd ("QUIT") );
  147.                   /* should look at reply but who cares */ 
  148. }
  149.  
  150. ph_pkinit ()                      /* initialize remote pickup            */
  151. {
  152.     char replybuf[128];
  153.     short retval;
  154. #ifdef DEBUG
  155.     ll_log (logptr, LLOGPTR, "ph_pkinit ()");
  156. #endif
  157.  
  158.     /* say we're listening */
  159.     sprintf (replybuf, "220 Server SMTP (Complaints/bugs to:  %s)",
  160.                supportaddr);
  161.     if (rp_isbad (retval = ph_wrec (replybuf, strlen(replybuf)))) 
  162.     return (retval);
  163.     return (RP_OK);
  164. }
  165.  
  166. ph_pkend ()                       /* done with pickup                   */
  167. {
  168. #ifdef DEBUG
  169.     ll_log (logptr, LLOGBTR, "ph_pkend ()");
  170. #endif
  171.     return (RP_OK);
  172. }
  173.